package com.ghr.common;

import com.ghr.common.enums.ErrorCode;
import com.ghr.common.enums.ErrorDesc;

/**
 * @author Gghr
 * @version 1.0
 * @date 2022/12/18 11:32
 */
@SuppressWarnings(value = "all")
public class ResultUtils {

    public static <T> Result<T> success(T data){
        return new Result<>(200, data,"success");
    }

    public static <T> Result<T> error(int code, String message){
        return new Result(code, null, message);
    }

    public static <T> Result<T> error(int code, String message, String description){
        return new Result(code, null, message, description);
    }

    public static <T> Result<T> error(ErrorCode errorCode, String message){
        return new Result(errorCode.getCode(), null, message);
    }

    public static <T> Result<T> error(ErrorCode errorCode, ErrorDesc errorDesc){
        return new Result<>(errorCode.getCode(),null, errorCode.getMessage(), errorDesc.getDescription());
    }

}
